package com.example.androidmainshixun.view;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.example.androidmainshixun.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;


public class AddAgroSchoolNews extends AppCompatActivity implements View.OnClickListener {
    private ImageView magroscnews_back_agro;
    private ImageView madd_image;
    private Button mbtn_register;
    private Uri selectedImageUri;
    private RecyclerView madded_recycler_view;
    private static final int PICK_IMAGE_REQUEST_CODE = 100;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_agro_school_news);
        magroscnews_back_agro = findViewById(R.id.agroscnews_back_agro);
        madd_image = findViewById(R.id.add_image);
        mbtn_register = findViewById(R.id.btn_register);

        magroscnews_back_agro.setOnClickListener(this);
        madd_image.setOnClickListener(this);
        mbtn_register.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.agroscnews_back_agro) {
            Intent intent = new Intent(AddAgroSchoolNews.this, AgroSchool.class);
            startActivity(intent);
        } else if (id == R.id.add_image) {
            Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(intent, PICK_IMAGE_REQUEST_CODE);
        } else if (id == R.id.btn_register) {
            Intent intent = new Intent(AddAgroSchoolNews.this, AgroSchool.class);
            startActivity(intent);

        }
        }
    /*@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == PICK_IMAGE_REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            selectedImageUri = data.getData();
            // 更新ImageView以显示选中的图片
            madd_image.setImageURI(selectedImageUri);
        }
    }*/
    /*SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
    String currentDate = dateFormat.format(new Date());*/
}